<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="88px">
      <el-form-item label="线索编号" prop="kznum">
        <el-input v-model="queryParams.kznum" placeholder="请输入线索编号" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="线索平台" prop="kzplatform">
        <el-input v-model="queryParams.kzplatform" placeholder="请输入线索平台" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="线索账户" prop="kzaccount">
        <el-input v-model="queryParams.kzaccount" placeholder="请输入线索账户" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="来源页面" prop="sourceWeb">
        <el-input v-model="queryParams.sourceWeb" placeholder="请输入来源页面" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="线索昵称" prop="kzNickname">
        <el-input v-model="queryParams.kzNickname" placeholder="请输入线索昵称" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="当前跟进人" prop="currentFollowupMan">
        <el-input v-model="queryParams.currentFollowupMan" placeholder="请输入当前跟进人" clearable
          @keyup.enter.native="handleQuery" />
      </el-form-item>

      <el-form-item label="跟进时间" prop="startfollowupTime">
        <el-date-picker clearable v-model="queryParams.startfollowupTime" type="date" value-format="yyyy-MM-dd"
          placeholder="请选择跟进开始时间">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="至" prop="startfollowupTime">
        <el-date-picker clearable v-model="queryParams.endfollowupTime" type="date" value-format="yyyy-MM-dd"
          placeholder="请选择跟进结束时间">
        </el-date-picker>
      </el-form-item>

      <el-form-item label="线索时间" prop="startKzTime">
        <el-date-picker clearable v-model="queryParams.startKzTime" type="date" value-format="yyyy-MM-dd"
          placeholder="请选择跟进时间">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="至" prop="startKzTime">
        <el-date-picker clearable v-model="queryParams.endKzTime" type="date" value-format="yyyy-MM-dd"
          placeholder="请选择跟进时间">
        </el-date-picker>
      </el-form-item>




      <!-- <el-form-item label="承运公司" prop="acceptCompany">
        <el-input
          v-model="queryParams.acceptCompany"
          placeholder="请输入承运公司"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item> -->
      <el-form-item label="始发地" prop="originPlace">
        <!-- 
        queryCitys: [],
    queryRegions: [],
    queryCitysAim: [],
    queryRegionsAim: [], -->
        <!-- <el-input v-model="queryParams.originPlace" placeholder="请输入始发地" clearable @keyup.enter.native="handleQuery" /> -->
        <el-select v-model="queryParams.province" placeholder="请选择省" style=" width:165px;" @change="getQueryCitys"
          clearable>
          <el-option v-for="item in provinces" :key="item.id" :label="item.cityName" :value="item.id"></el-option>
        </el-select>

        <el-select v-model="queryParams.city" placeholder="请选择市" style=" width:165px;margin-left: 20px"
          @change="getQueryregions" clearable>
          <el-option v-for="item in queryCitys" :key="item.id" :label="item.cityName" :value="item.id"></el-option>
        </el-select>

        <el-select v-model="queryParams.region" placeholder="请选择区" style=" width:165px;margin-left: 20px" clearable>
          <el-option v-for="item in queryRegions " :key="item.id" :label="item.cityName" :value="item.id"></el-option>
        </el-select>


      </el-form-item>





      <el-form-item label="目的地" prop="aimPlace">
        <el-select v-model="queryParams.aimProvince" placeholder="请选择省" style=" width:165px" @change="getQueryCitysAim"
          clearable>
          <el-option v-for="item in provinces" :key="item.id" :label="item.cityName" :value="item.id"></el-option>
        </el-select>

        <el-select v-model="queryParams.aimCity" placeholder="请选择市" style=" width:165px;margin-left: 20px"
          @change="getQueryregionsAim" clearable>
          <el-option v-for="item in queryCitysAim" :key="item.id" :label="item.cityName" :value="item.id"></el-option>
        </el-select>

        <el-select v-model="queryParams.aimRegion" placeholder="请选择区" style=" width:165px;margin-left: 20px" clearable>
          <el-option v-for="item in queryRegionsAim " :key="item.id" :label="item.cityName"
            :value="item.id"></el-option>
        </el-select>
      </el-form-item>

      <!-- <el-form-item label="标签" prop="tags">
        <el-input v-model="queryParams.tags" placeholder="请输入标签" clearable @keyup.enter.native="handleQuery" />
      </el-form-item> -->
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd">新增</el-button>
      </el-col>
      <el-tag style="margin-left:10px"> 待联系线索数:{{ statistInfo.unContactCount }} </el-tag>
      <el-tag style="margin-left:10px"> 联系中线索数:{{ statistInfo.contactingCount }} </el-tag>
      <el-tag style="margin-left:10px"> 移交报价线索数:{{ statistInfo.unpriceCount }} </el-tag>

      <!-- <el-col :span="1.5">
        <el-button type="danger" plain icon="el-icon-delete" size="mini" :disabled="multiple" @click="handleDelete"
          v-hasPermi="['system:clue:remove']">删除</el-button>
      </el-col> -->
      <el-col :span="1.5">
        <el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport"
          v-hasPermi="['system:clue:export']">导出</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="clueList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="线索编号" align="center" prop="kznum" />
      <el-table-column label="线索平台" align="center" prop="kzplatform" />
      <el-table-column label="线索账户" align="center" prop="kzaccount" />
      <el-table-column label="来源页面" align="center" prop="sourceWeb" />
      <el-table-column label="线索昵称" align="center" prop="kzNickname" />
      <el-table-column label="线索电话" align="center" prop="kzphoneNumber" />
      <el-table-column label="主播名称" align="center" prop="anchor.nickName">
        <template slot-scope="scope">
          <el-button size="mini" type="text" @click="checkAnchor(scope.row)">{{
            scope.row.anchor != null ? scope.row.anchor.nickName : '无' }}</el-button>
        </template>
      </el-table-column>


      <el-table-column label="始发地" align="center" prop="originPlaceDetail">
        <template slot-scope="scope">
          <span>{{ (scope.row.provinceString) }}/{{ (scope.row.cityString) }}/{{ (scope.row.regionString) }}</span>
        </template>
      </el-table-column>
      <el-table-column label="目的地" align="center" prop="aimPlaceDetail">

        <template slot-scope="scope">
          <span>{{ (scope.row.aimProvinceString) }}/{{ (scope.row.aimCityString) }}/{{ (scope.row.aimRegionString)
            }}</span>
        </template>
      </el-table-column>


      <el-table-column label="车型" align="center" prop="vehicleTypeOne" />
      <el-table-column label="标签" align="center" prop="tags" />
      <el-table-column label="当前跟进人" align="center" prop="currentFollowupMan" />
      <el-table-column label="当前跟进时间" align="center" prop="followupTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.followupTime, '{y}-{m}-{d} {h}:{i}:{s}') }}</span>
        </template>
      </el-table-column>

      <el-table-column label="状态" align="center" prop="status">
        <template slot-scope="scope">
          <span v-if="scope.row.status == 0 || scope.row.status == null">待联系</span>
          <span v-if="scope.row.status == 1">联系中</span>
          <span v-if="scope.row.status == 2">已移交报价</span>
          <span v-if="scope.row.status == 3">报价中</span>
          <span v-if="scope.row.status == 4">已完成</span>
        </template>
      </el-table-column>

      <el-table-column label="线索时间" align="center" prop="followupTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.createTime) }}</span>
        </template>
      </el-table-column>



      <!-- <el-table-column label="承运公司" align="center" prop="acceptCompany" />
      <el-table-column label="运费" align="center" prop="transFee" />
      <el-table-column label="报价单编号" align="center" prop="priceNum" />
      <el-table-column label="报价时间" align="center" prop="priceTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.priceTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="报价" align="center" prop="price" />
      <el-table-column label="标签" align="center" prop="tags" />
      <el-table-column label="车辆估值" align="center" prop="vehicleEstimationValue" />
      <el-table-column label="备注" align="center" prop="remarks" /> -->
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button size="mini" v-if="scope.row.status > 1" type="text" @click="checkInfo(scope.row, 1)">查看</el-button>
          <el-button size="mini" v-if="scope.row.status < 2" type="text"
            @click="handleUpdate(scope.row, 2)">跟进</el-button>

          <el-button v-if="scope.row.status < 2" size="mini" type="text" @click="toPrice(scope.row)">移交报价</el-button>

          <!-- <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['system:clue:remove']"
          >删除</el-button> -->
        </template>
      </el-table-column>
    </el-table>

    <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
      @pagination="getList" />

    <!-- 查看信息 -->
    <el-dialog :title="title" :visible.sync="openStep" width="500px" append-to-body>
      <el-form ref="stepForm" :model="form" :rules="rules" label-width="100px">
        <!-- <el-form-item label="线索id" prop="clueId">
          <el-input v-model="form.clueId" placeholder="请输入线索id" />
        </el-form-item> -->
        <el-form-item label="跟进电话">
          {{ currentPhone }}
        </el-form-item>
        <el-form-item label="跟进内容">
          <el-input v-model="stepForm.content" type="textarea" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitStepForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>

    <el-dialog width="1250px" :visible.sync="checkOpen" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="90px">


        <h3>基本信息</h3>

        <div class="row-between" style="width: 100%;">
          <div style="width: 75%;">
            <el-row>
              <el-col :span="7">
                <el-form-item label="线索编号" prop="kznum">
                  <span>{{ form.kznum }}</span>
                  <!-- <el-input v-model="form.kznum" placeholder="请输入线索编号" maxlength="30" /> -->
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item label="线索时间" prop="kzplatform">
                  <span>{{ form.createTime }}</span>
                  <!-- <el-input v-model="form.kzplatform" placeholder="请输入线索平台" maxlength="30" /> -->
                </el-form-item>
              </el-col>

              <el-col :span="6">
                <el-form-item label="主机构" prop="kzplatform">
                  <span>{{ form.kzplatform }}</span>
                  <!-- <el-input v-model="form.kzplatform" placeholder="请输入线索平台" maxlength="30" /> -->
                </el-form-item>
              </el-col>
            </el-row>

            <h3>基本信息</h3>
            <el-row>
              <el-col :span="6">

                <el-form-item label="线索平台" prop="kzplatform">
                  <span>{{ form.kzplatform }}</span>
                  <!-- <el-input v-model="form.kzplatform" placeholder="请输入线索平台" maxlength="30" /> -->
                </el-form-item>
              </el-col>


              <el-col :span="6">
                <el-form-item label="线索账户" prop="kzaccount">
                  <span>{{ form.kzaccount }}</span>
                  <!-- <el-input v-model="form.kzaccount" placeholder="请输入线索账户" /> -->
                </el-form-item>
              </el-col>

              <el-col :span="6">
                <el-form-item label="来源页面" prop="sourceWeb">
                  <span>{{ form.sourceWeb }}</span>
                  <!-- <el-input v-model="form.sourceWeb" placeholder="请输入来源页面" /> -->
                </el-form-item>
              </el-col>
            </el-row>



            <h3>客户信息</h3>
            <el-row>
              <el-col :span="6">
                <el-form-item label="线索昵称" prop="kzNickname">
                  <span>{{ form.kzNickname }}</span>
                </el-form-item>
              </el-col>


              <el-col :span="6">
                <el-form-item label="线索电话" prop="kzphoneNumber">
                  <span>{{ form.kzphoneNumber }}</span>
                </el-form-item>
              </el-col>

              <el-col :span="6">
                <el-form-item label="车型" prop="vehicleTypeOne">
                  <el-select v-model="form.vehicleTypeOne" placeholder="请选择标签" disabled>
                    <el-option v-for="dict in taglistOptions.vehicleTypes" :key="dict.tagName" :label="dict.tagName"
                      :value="dict.tagName" />
                  </el-select>
                </el-form-item>
              </el-col>
            </el-row>



            <!-- <h3>标签信息</h3>
            <el-row>
              <el-col :span="14">
                <el-form-item label="标签" prop="tags">
                  <el-select v-model="form.tags" placeholder="请选择标签 " disabled>
                    <el-option v-for="dict in taglistOptions.clueTagList" :key="dict.tagName" :label="dict.tagName"
                      :value="dict.tagName" />
                  </el-select>
                </el-form-item>
              </el-col>
            </el-row> -->


            <h3>车辆信息</h3>
            <el-row>
              <el-col :span="6">
                <el-form-item label="标签" prop="vehicleTypeOne">
                  <el-select v-model="form.vehicleTypeOne" placeholder="请选择标签" disabled>
                    <el-option v-for="dict in taglistOptions.vehicleTypes" :key="dict.tagName" :label="dict.tagName"
                      :value="dict.tagName" />
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item label="车辆估值" prop="vehicleEstimationValue">
                  <el-input v-model="form.vehicleEstimationValue" disabled placeholder="请输入车辆估值" />
                </el-form-item>
              </el-col>
            </el-row>


            <h3>路线信息</h3>
            <el-row>

              <el-col :span="1">
                <el-form-item label="始发地">
                </el-form-item>
              </el-col>
              <el-col :span="5">
                <el-form-item label="省" prop="province">
                  <el-select v-model="form.province" placeholder="请选择" disabled @change="getCitys" clearable>
                    <el-option v-for="item in provinces" :key="item.id" :label="item.cityName"
                      :value="item.id"></el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="5">
                <el-form-item label="市" prop="city">
                  <el-select v-model="form.city" placeholder="请选择" @change="getregions" disabled>
                    <el-option v-for="item in citys" :key="item.id" :label="item.cityName" :value="item.id"></el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="5">
                <el-form-item label="区" prop="region">
                  <el-select v-model="form.region" placeholder="请选择" disabled>
                    <el-option v-for="item in regions" :key="item.id" :label="item.cityName"
                      :value="item.id"></el-option>
                  </el-select>
                </el-form-item>
              </el-col>

              <!-- <el-col :span="6">
                <el-form-item label="始发地" prop="originPlace">
                  <el-select v-model="form.originPlace" placeholder="请选择始发地" clearable>
                    <el-option v-for="dict in chinaList" :key="dict.cityName" :label="dict.cityName"
                      :value="dict.cityName" />
                  </el-select>
                </el-form-item>
              </el-col> -->
              <el-col :span="16">
                <el-form-item label="详细信息" prop="originPlaceDetail">
                  <el-input v-model="form.originPlaceDetail" disabled placeholder="请输入车辆估值" />
                </el-form-item>
              </el-col>
            </el-row>


            <el-row>

              <el-col :span="1">
                <el-form-item label="目的地">
                </el-form-item>
              </el-col>
              <el-col :span="5">
                <el-form-item label="省" prop="aimProvince">
                  <el-select v-model="form.aimProvince" placeholder="请选择" disabled @change="getCitysAim">
                    <el-option v-for="item in provinces" :key="item.id" :label="item.cityName"
                      :value="item.id"></el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="5">
                <el-form-item label="市" prop="aimCity">
                  <el-select v-model="form.aimCity" placeholder="请选择" disabled @change="getregionsAim">
                    <el-option v-for="item in citysAim" :key="item.id" :label="item.cityName"
                      :value="item.id"></el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="5">
                <el-form-item label="区" prop="aimRegion">
                  <el-select v-model="form.aimRegion" disabled placeholder="请选择">
                    <el-option v-for="item in regionsAim" :key="item.id" :label="item.cityName"
                      :value="item.id"></el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <!-- <el-col :span="6">
                <el-form-item label="目的地" prop="aimPlace">
                  <el-input v-model="form.aimPlace" placeholder="请输入目的地" />
                </el-form-item>
              </el-col> -->

              <el-col :span="16">
                <el-form-item label="详细信息" prop="aimPlaceDetail">
                  <el-input v-model="form.aimPlaceDetail" disabled placeholder="请输入车辆估值" />
                </el-form-item>
              </el-col>
            </el-row>
          </div>
          <div style="width: 25%;height: 100%;">
            <el-timeline>
              <el-timeline-item v-for="(activity, index) in form.followList" :key="index"
                :timestamp="activity.createTime + '  ' + activity.stepUserName">
                {{ activity.content }}
              </el-timeline-item>
            </el-timeline>
          </div>
        </div>










        <!-- <el-form-item label="车辆估值" prop="vehicleEstimationValue">
          <el-input v-model="form.vehicleEstimationValue" placeholder="请输入车辆估值" />
        </el-form-item> -->

        <!-- <el-form-item label="车辆类型" prop="vehicleTypeOne">
          <el-input v-model="form.vehicleTypeOne" placeholder="请输入车辆类型" />
        </el-form-item>
        <el-form-item label="车辆类型二" prop="vehicleTypeTwo">
          <el-input v-model="form.vehicleTypeTwo" placeholder="请输入车辆类型二" />
        </el-form-item> -->
        <!-- <el-form-item label="当前跟进时间" prop="followupTime">
          <el-date-picker clearable
            v-model="form.followupTime"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择当前跟进时间">
          </el-date-picker>
        </el-form-item> -->
        <!-- <el-form-item label="当前跟进人" prop="currentFollowupMan">
          <el-input v-model="form.currentFollowupMan" placeholder="请输入当前跟进人" />
        </el-form-item>
        <el-form-item label="承运公司" prop="acceptCompany">
          <el-input v-model="form.acceptCompany" placeholder="请输入承运公司" />
        </el-form-item> -->
        <!-- <el-form-item label="始发地" prop="originPlace">
          <el-input v-model="form.originPlace" placeholder="请输入始发地" />
        </el-form-item>
        <el-form-item label="目的地" prop="aimPlace">
          <el-input v-model="form.aimPlace" placeholder="请输入目的地" />
        </el-form-item> -->
        <!-- <el-form-item label="运费" prop="transFee">
          <el-input v-model="form.transFee" placeholder="请输入运费" />
        </el-form-item>
        <el-form-item label="报价单编号" prop="priceNum">
          <el-input v-model="form.priceNum" placeholder="请输入报价单编号" />
        </el-form-item>
        <el-form-item label="报价时间" prop="priceTime">
          <el-date-picker clearable
            v-model="form.priceTime"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择报价时间">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="报价" prop="price">
          <el-input v-model="form.price" placeholder="请输入报价" />
        </el-form-item> -->

        <!-- <el-form-item label="备注" prop="remarks">
          <el-input v-model="form.remarks" placeholder="请输入备注" />
        </el-form-item> -->
      </el-form>



      <h3>跟进记录</h3>
      <el-table v-loading="loading" :data="form.followList">
        <el-table-column label="序号" align="center">
          <template slot-scope="scope">
            <span> {{ scope.$index + 1 }}</span>
          </template>
        </el-table-column>
        <el-table-column label="联系内容" align="center" prop="content" />
        <el-table-column label="操作人" align="center" prop="stepUserName" />
        <el-table-column label="线索时间" align="center" prop="createTime" />
      </el-table>

      <h3>填写跟进内容</h3>
      <el-form ref="stepForm" :model="form" :rules="rules" label-width="100px">
        <!-- <el-form-item label="线索id" prop="clueId">
          <el-input v-model="form.clueId" placeholder="请输入线索id" />
        </el-form-item> -->
        <el-form-item label="跟进内容">
          <el-input v-model="stepForm.content" disabled type="textarea" />
        </el-form-item>
      </el-form>

      <!-- <div slot="footer" class="dialog-footer">
        <el-button v-if="operateType == 2" type="primary" @click="submitStepForm">确认跟进</el-button>
        <el-button v-if="form.status < 2 && operateType == 1" type="primary" @click="submitForm">保存</el-button>
        <el-button v-if="form.status < 2 && operateType == 1" type="primary" @click="submitPriceForm">移交报价</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div> -->
    </el-dialog>

    <!-- 主播弹框 -->
    <el-dialog :visible.sync="anchorOpen" width="600px" append-to-body>
      <el-form label-width="90px">
        <el-row>
          <el-col :span="12">
            <el-form-item label="用户昵称:" prop="nickName">
              {{ anchorInfo.nickName }}
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="用户性别:">
              {{ anchorInfo.sex == 0 ? '男' : '女' }}
            </el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col :span="12">
            <el-form-item label="手机号码:" prop="phonenumber">
              {{ anchorInfo.phonenumber }}
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="邮箱:" prop="email">
              {{ anchorInfo.email }}
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
    </el-dialog>

    <!-- 修改和跟进信息 -->
    <el-dialog width="1250px" :visible.sync="open" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="90px">


        <h3>基本信息</h3>

        <div class="row-between" style="width: 100%;">
          <div style="width: 75%;">
            <el-row>
              <el-col :span="7">
                <el-form-item label="线索编号" prop="kznum">
                  <span>{{ form.kznum }}</span>
                  <!-- <el-input v-model="form.kznum" placeholder="请输入线索编号" maxlength="30" /> -->
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item label="线索时间" prop="kzplatform">
                  <span>{{ form.createTime }}</span>
                  <!-- <el-input v-model="form.kzplatform" placeholder="请输入线索平台" maxlength="30" /> -->
                </el-form-item>
              </el-col>

              <el-col :span="6">
                <el-form-item label="主机构" prop="kzplatform">
                  <span>{{ form.kzplatform }}</span>
                  <!-- <el-input v-model="form.kzplatform" placeholder="请输入线索平台" maxlength="30" /> -->
                </el-form-item>
              </el-col>
            </el-row>

            <h3>基本信息</h3>
            <el-row>
              <el-col :span="6">

                <el-form-item label="线索平台" prop="kzplatform">
                  <span>{{ form.kzplatform }}</span>
                  <!-- <el-input v-model="form.kzplatform" placeholder="请输入线索平台" maxlength="30" /> -->
                </el-form-item>
              </el-col>


              <el-col :span="6">
                <el-form-item label="线索账户" prop="kzaccount">
                  <span>{{ form.kzaccount }}</span>
                  <!-- <el-input v-model="form.kzaccount" placeholder="请输入线索账户" /> -->
                </el-form-item>
              </el-col>

              <el-col :span="6">
                <el-form-item label="来源页面" prop="sourceWeb">
                  <span>{{ form.sourceWeb }}</span>
                  <!-- <el-input v-model="form.sourceWeb" placeholder="请输入来源页面" /> -->
                </el-form-item>
              </el-col>
            </el-row>



            <h3>客户信息</h3>
            <el-row>
              <el-col :span="6">
                <el-form-item label="线索昵称" prop="kzNickname">
                  <!-- <span>{{ form.kzNickname }}</span>   -->
                  <el-input v-model="form.kzNickname" placeholder="请输入线索昵称" />
                </el-form-item>
              </el-col>


              <el-col :span="6">
                <el-form-item label="线索电话" prop="kzphoneNumber">
                  <!-- <span>{{ form.kzphoneNumber }}</span> -->
                  <el-input v-model="form.kzphoneNumber" placeholder="请输入线索电话" />
                </el-form-item>
              </el-col>

              <el-col :span="6">
                <el-form-item label="车型" prop="vehicleTypeOne">
                  <!-- <span>{{ form.vehicleTypeOne }}</span> -->
                  <el-select v-model="form.vehicleTypeOne" placeholder="请选择标签" clearable>
                    <el-option v-for="dict in taglistOptions.vehicleTypes" :key="dict.tagName" :label="dict.tagName"
                      :value="dict.tagName" />
                  </el-select>
                </el-form-item>
              </el-col>
            </el-row>



            <!-- <h3>标签信息</h3>
            <el-row>
              <el-col :span="14">
                <el-form-item label="标签" prop="tags">
                  <el-select v-model="form.tags" placeholder="请选择标签" clearable>
                    <el-option v-for="dict in taglistOptions.clueTagList" :key="dict.tagName" :label="dict.tagName"
                      :value="dict.tagName" />
                  </el-select>
                </el-form-item>
              </el-col>
            </el-row> -->


            <h3>车辆信息</h3>
            <el-row>
              <el-col :span="6">
                <el-form-item label="标签" prop="vehicleTypeOne">
                  <!-- <el-select v-model="form.vehicleTypeOne" placeholder="请选择标签" clearable>
                    <el-option v-for="dict in taglistOptions.vehicleTypes" :key="dict.tagName" :label="dict.tagName"
                      :value="dict.tagName" />
                  </el-select> -->
                  <el-select v-model="form.tags" placeholder="请选择标签" clearable>
                    <el-option v-for="dict in taglistOptions.clueTagList" :key="dict.tagName" :label="dict.tagName"
                      :value="dict.tagName" />
                  </el-select>

                </el-form-item>




              </el-col>
              <el-col :span="6">
                <el-form-item label="车辆估值" prop="vehicleEstimationValue">
                  <el-input v-model="form.vehicleEstimationValue" placeholder="请输入车辆估值" />
                </el-form-item>
              </el-col>
            </el-row>


            <h3>路线信息</h3>
            <el-row>

              <el-col :span="1">
                <el-form-item label="始发地">
                </el-form-item>
              </el-col>
              <el-col :span="5">
                <el-form-item label="省" prop="province">
                  <el-select v-model="form.province" placeholder="请选择" @change="getCitys" clearable>
                    <el-option v-for="item in provinces" :key="item.id" :label="item.cityName"
                      :value="item.id"></el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="5">
                <el-form-item label="市" prop="city">
                  <el-select v-model="form.city" placeholder="请选择" @change="getregions" clearable>
                    <el-option v-for="item in citys" :key="item.id" :label="item.cityName" :value="item.id"></el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="5">
                <el-form-item label="区" prop="region">
                  <el-select v-model="form.region" placeholder="请选择" clearable>
                    <el-option v-for="item in regions" :key="item.id" :label="item.cityName"
                      :value="item.id"></el-option>
                  </el-select>
                </el-form-item>
              </el-col>

              <!-- <el-col :span="6">
                <el-form-item label="始发地" prop="originPlace">
                  <el-select v-model="form.originPlace" placeholder="请选择始发地" clearable>
                    <el-option v-for="dict in chinaList" :key="dict.cityName" :label="dict.cityName"
                      :value="dict.cityName" />
                  </el-select>
                </el-form-item>
              </el-col> -->
              <el-col :span="16">
                <el-form-item label="详细信息" prop="originPlaceDetail">
                  <el-input v-model="form.originPlaceDetail" placeholder="请输入车辆估值" />
                </el-form-item>
              </el-col>
            </el-row>


            <el-row>

              <el-col :span="1">
                <el-form-item label="目的地">
                </el-form-item>
              </el-col>
              <el-col :span="5">
                <el-form-item label="省" prop="aimProvince">
                  <el-select v-model="form.aimProvince" placeholder="请选择" @change="getCitysAim">
                    <el-option v-for="item in provinces" :key="item.id" :label="item.cityName"
                      :value="item.id"></el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="5">
                <el-form-item label="市" prop="aimCity">
                  <el-select v-model="form.aimCity" placeholder="请选择" @change="getregionsAim">
                    <el-option v-for="item in citysAim" :key="item.id" :label="item.cityName"
                      :value="item.id"></el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="5">
                <el-form-item label="区" prop="aimRegion">
                  <el-select v-model="form.aimRegion" placeholder="请选择">
                    <el-option v-for="item in regionsAim" :key="item.id" :label="item.cityName"
                      :value="item.id"></el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <!-- <el-col :span="6">
                <el-form-item label="目的地" prop="aimPlace">
                  <el-input v-model="form.aimPlace" placeholder="请输入目的地" />
                </el-form-item>
              </el-col> -->

              <el-col :span="16">
                <el-form-item label="详细信息" prop="aimPlaceDetail">
                  <el-input v-model="form.aimPlaceDetail" placeholder="请输入车辆估值" />
                </el-form-item>
              </el-col>
            </el-row>
          </div>
          <div style="width: 25%;height: 100%;">
            <el-timeline>
              <el-timeline-item v-for="(activity, index) in form.followList" :key="index"
                :timestamp="activity.createTime + '  ' + activity.stepUserName">
                {{ activity.content }}
              </el-timeline-item>
            </el-timeline>
          </div>
        </div>










        <!-- <el-form-item label="车辆估值" prop="vehicleEstimationValue">
          <el-input v-model="form.vehicleEstimationValue" placeholder="请输入车辆估值" />
        </el-form-item> -->

        <!-- <el-form-item label="车辆类型" prop="vehicleTypeOne">
          <el-input v-model="form.vehicleTypeOne" placeholder="请输入车辆类型" />
        </el-form-item>
        <el-form-item label="车辆类型二" prop="vehicleTypeTwo">
          <el-input v-model="form.vehicleTypeTwo" placeholder="请输入车辆类型二" />
        </el-form-item> -->
        <!-- <el-form-item label="当前跟进时间" prop="followupTime">
          <el-date-picker clearable
            v-model="form.followupTime"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择当前跟进时间">
          </el-date-picker>
        </el-form-item> -->
        <!-- <el-form-item label="当前跟进人" prop="currentFollowupMan">
          <el-input v-model="form.currentFollowupMan" placeholder="请输入当前跟进人" />
        </el-form-item>
        <el-form-item label="承运公司" prop="acceptCompany">
          <el-input v-model="form.acceptCompany" placeholder="请输入承运公司" />
        </el-form-item> -->
        <!-- <el-form-item label="始发地" prop="originPlace">
          <el-input v-model="form.originPlace" placeholder="请输入始发地" />
        </el-form-item>
        <el-form-item label="目的地" prop="aimPlace">
          <el-input v-model="form.aimPlace" placeholder="请输入目的地" />
        </el-form-item> -->
        <!-- <el-form-item label="运费" prop="transFee">
          <el-input v-model="form.transFee" placeholder="请输入运费" />
        </el-form-item>
        <el-form-item label="报价单编号" prop="priceNum">
          <el-input v-model="form.priceNum" placeholder="请输入报价单编号" />
        </el-form-item>
        <el-form-item label="报价时间" prop="priceTime">
          <el-date-picker clearable
            v-model="form.priceTime"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择报价时间">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="报价" prop="price">
          <el-input v-model="form.price" placeholder="请输入报价" />
        </el-form-item> -->

        <!-- <el-form-item label="备注" prop="remarks">
          <el-input v-model="form.remarks" placeholder="请输入备注" />
        </el-form-item> -->
      </el-form>



      <h3>跟进记录</h3>
      <el-table v-loading="loading" :data="form.followList">
        <el-table-column label="序号" align="center">
          <template slot-scope="scope">
            <span> {{ scope.$index + 1 }}</span>
          </template>
        </el-table-column>
        <el-table-column label="联系内容" align="center" prop="content" />
        <el-table-column label="操作人" align="center" prop="stepUserName" />
        <el-table-column label="线索时间" align="center" prop="createTime" />
      </el-table>

      <h3>填写跟进内容</h3>
      <el-form ref="stepForm" :model="form" :rules="rules" label-width="100px">
        <!-- <el-form-item label="线索id" prop="clueId">
          <el-input v-model="form.clueId" placeholder="请输入线索id" />
        </el-form-item> -->
        <el-form-item label="跟进内容">
          <el-input v-model="stepForm.content" type="textarea" />
        </el-form-item>
      </el-form>

      <div slot="footer" class="dialog-footer">
        <el-button v-if="operateType == 2" type="primary" @click="submitStepForm">确认跟进</el-button>
        <el-button v-if="form.status < 2 && operateType == 1" type="primary" @click="submitForm">保存</el-button>
        <el-button v-if="form.status < 2 && operateType == 1" type="primary" @click="submitPriceForm">移交报价</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>

    <!-- 添加或修改【请填写功能名称】对话框 -->
    <el-dialog title="新增线索" :visible.sync="addOpen" width="1200px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="100px">
        <h3>基本信息</h3>
        <div>
          <div>
            <el-row>
              <!-- <el-col :span="6">
                <el-form-item label="线索编号" prop="kznum">
                  <el-input v-model="form.kznum" placeholder="请输入线索编号" maxlength="30" />
                </el-form-item>
              </el-col> -->
              <!-- <el-col :span="6">
                <el-form-item label="线索平台" prop="kzplatform">
                  <el-input v-model="form.kzplatform" placeholder="请输入线索平台" maxlength="30" />
                </el-form-item>
              </el-col> -->
              <el-col :span="6">
                <el-form-item label="主机构" prop="kzplatform">
                  <span>运车网</span>
                  <!-- <el-input v-model="form.kzplatform" placeholder="请输入线索平台" maxlength="30" /> -->
                </el-form-item>
              </el-col>
            </el-row>
            <h3>基本信息</h3>
            <el-row>
              <el-col :span="6">
                <el-form-item label="线索平台" prop="kzplatform">
                  <el-input v-model="form.kzplatform" placeholder="请输入线索平台" maxlength="30" />
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item label="线索账户" prop="kzaccount">
                  <el-input v-model="form.kzaccount" placeholder="请输入线索账户" />
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item label="来源页面" prop="sourceWeb">
                  <el-input v-model="form.sourceWeb" placeholder="请输入来源页面" />
                </el-form-item>
              </el-col>
            </el-row>
            <h3>客户信息</h3>
            <el-row>
              <el-col :span="6">
                <el-form-item label="线索昵称" prop="kzNickname">
                  <el-input v-model="form.kzNickname" placeholder="请输入线索昵称" />
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item label="线索电话" prop="kzphoneNumber">
                  <el-input v-model="form.kzphoneNumber" placeholder="请输入线索电话" />
                </el-form-item>
              </el-col>

              <el-col :span="6">
                <el-form-item label="车型" prop="vehicleTypeOne">
                  <!-- <el-input v-model="form.vehicleTypeOne" placeholder="请输入车辆类型" /> -->
                  <el-select v-model="form.vehicleTypeOne" placeholder="请选择标签" clearable>
                    <el-option v-for="dict in taglistOptions.clueTagList" :key="dict.tagName" :label="dict.tagName"
                      :value="dict.tagName" />
                  </el-select>


                </el-form-item>
              </el-col>
            </el-row>
            <!-- <h3>标签信息</h3>
            <el-row>
              <el-col :span="14">
                <el-form-item label="标签" prop="tags">
                  <el-select v-model="form.tags" placeholder="请选择标签" clearable>
                    <el-option v-for="dict in taglistOptions.clueTagList" :key="dict.tagName" :label="dict.tagName"
                      :value="dict.tagName" />
                  </el-select>
                </el-form-item>
              </el-col>
            </el-row> -->
            <h3>车辆信息</h3>
            <el-row>
              <el-col :span="6">
                <el-form-item label="标签" prop="tags">
                  <el-select v-model="form.tags" placeholder="请选择标签" clearable>
                    <el-option v-for="dict in taglistOptions.vehicleTypes" :key="dict.tagName" :label="dict.tagName"
                      :value="dict.tagName" />
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item label="车辆估值" prop="vehicleEstimationValue">
                  <el-input v-model="form.vehicleEstimationValue" placeholder="请输入车辆估值" />
                </el-form-item>
              </el-col>
            </el-row>
            <h3>路线信息</h3>
            <el-row>


              <el-col :span="1">
                <el-form-item label="始发地">
                </el-form-item>
              </el-col>
              <el-col :span="5">
                <el-form-item label="省" prop="province">
                  <el-select v-model="form.province" placeholder="请选择" @change="getCitys" clearable>
                    <el-option v-for="item in provinces" :key="item.id" :label="item.cityName"
                      :value="item.id"></el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="5">
                <el-form-item label="市" prop="city">
                  <el-select v-model="form.city" placeholder="请选择" @change="getregions" clearable>
                    <el-option v-for="item in citys" :key="item.id" :label="item.cityName" :value="item.id"></el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="5">
                <el-form-item label="区" prop="region" clearable>
                  <el-select v-model="form.region" placeholder="请选择">
                    <el-option v-for="item in regions" :key="item.id" :label="item.cityName"
                      :value="item.id"></el-option>
                  </el-select>
                </el-form-item>
              </el-col>


              <!-- <el-form-item label="始发地" prop="originPlace">
                  <el-select v-model="form.originPlace" placeholder="请选择始发地" clearable>
                    <el-option v-for="dict in chinaList" :key="dict.cityName" :label="dict.cityName"
                      :value="dict.cityName" />
                  </el-select>
                </el-form-item> -->
            </el-row>
            <el-row>
              <el-col :span="10">
                <el-form-item label="详细信息" prop="originPlaceDetail">
                  <el-input v-model="form.originPlaceDetail" placeholder="请输入车辆估值" />
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="1">
                <el-form-item label="目的地">
                </el-form-item>
              </el-col>
              <el-col :span="5">
                <el-form-item label="省" prop="aimProvince">
                  <el-select v-model="form.aimProvince" placeholder="请选择" @change="getCitysAim">
                    <el-option v-for="item in provinces" :key="item.id" :label="item.cityName"
                      :value="item.id"></el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="5">
                <el-form-item label="市" prop="aimCity">
                  <el-select v-model="form.aimCity" placeholder="请选择" @change="getregionsAim">
                    <el-option v-for="item in citysAim" :key="item.id" :label="item.cityName"
                      :value="item.id"></el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="5">
                <el-form-item label="区" prop="aimRegion">
                  <el-select v-model="form.aimRegion" placeholder="请选择">
                    <el-option v-for="item in regionsAim" :key="item.id" :label="item.cityName"
                      :value="item.id"></el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <!-- <el-col :span="6">
                <el-form-item label="目的地" prop="aimPlace">
                  <el-input v-model="form.aimPlace" placeholder="请输入目的地" />
                </el-form-item>
              </el-col> -->
              <el-col :span="10">
                <el-form-item label="详细信息" prop="aimPlaceDetail">
                  <el-input v-model="form.aimPlaceDetail" placeholder="请输入详细信息" />
                </el-form-item>
              </el-col>
            </el-row>
          </div>
        </div>
      </el-form>

      <div slot="footer" class="dialog-footer">
        <el-button v-if="form.status < 2" type="primary" @click="submitForm">确定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { listClue, getClue, delClue, addClue, updateClue, getclueStatistState } from "@/api/crm/clue";
import { listStep, getStep, delStep, addStep, updateStep } from "@/api/crm/step";
import { getlistAllTypes } from "@/api/crm/tag";
import { listChina } from "@/api/crm/china";
import { getUser } from "@/api/system/user";

export default {
  name: "Clue",
  data() {
    return {
      //时间条
      reverse: true,
      activities: [{
        content: '活动按期开始',
        timestamp: '2018-04-15'
      }, {
        content: '通过审核',
        timestamp: '2018-04-13'
      }, {
        content: '创建成功',
        timestamp: '2018-04-11'
      }],
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      statistInfo: {},
      // 总条数
      total: 0,
      // 【请填写功能名称】表格数据
      clueList: [],
      // 弹出层标题
      title: "",
      anchorOpen: false,
      anchorInfo: {},
      // 是否显示弹出层
      open: false,
      addOpen: false,
      openStep: false,
      checkOpen: false,
      currentClueId: 0,
      currentPhone: '',
      operateType: 0,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        kznum: null,
        kzplatform: null,
        kzaccount: null,
        sourceWeb: null,
        kzNickname: null,
        vehicleEstimationValue: null,
        kzphoneNumber: null,
        vehicleTypeOne: null,
        vehicleTypeTwo: null,
        followupTime: null,
        currentFollowupMan: null,
        status: null,
        acceptCompany: null,
        originPlace: null,
        aimPlace: null,
        transFee: null,
        priceNum: null,
        priceTime: null,
        price: null,
        tags: null,
        remarks: null,
        startfollowupTime: null,
        endfollowupTime: null,
        startKzTime: null,
        endKzTime: null,
        province: null,
        city: null,
        region: null,
        aimProvince: null,
        aimCity: null,
        aimRegion: null,
      },

      queryCitys: [],
      queryRegions: [],
      queryCitysAim: [],
      queryRegionsAim: [],
      // 表单参数
      form: {},
      stepForm: {},
      tagItems: [],
      chinaList: [],
      provincelist: [],
      cityslist: [],
      regionslist: [],
      provinces: [],
      citys: [],
      regions: [],
      provincesAim: [],
      citysAim: [],
      regionsAim: [],
      currentStatus: 0,
      taglistOptions: {},
      // 表单校验
      rules: {
        kzphoneNumber: [
          { required: true, message: "请输入线索电话", trigger: "blur" }
        ],
      }
    };
  },
  created() {
    this.getList();
    this.getlistAllTypes();
    this.getlistChina();

  },
  methods: {


    //////
    getlistChina() {
      var queryParams1 = {
        pageNum: 1,
        pageSize: 10000,
      };
      listChina(queryParams1).then(response => {
        this.provinces = response.rows.filter(item => item.depth == 1);
        this.cityslist = response.rows.filter(item => item.depth == 2);
        this.regionslist = response.rows.filter(item => item.depth == 3);


        // this.citys = response.rows.filter(item => item.depth == 2);
        // this.regions = response.rows.filter(item => item.depth == 3);

        this.citysAim = this.citys;
        this.regionsAim = this.regions;
      });
    },
    /////



    togetclueStatistState() {
      getclueStatistState().then(response => {
        this.statistInfo = response.data;
      });
    },

    getQueryCitys(value) {
      this.queryCitys = this.cityslist.filter(item => parseInt(item.parentId) == parseInt(value));
      this.queryParams.city = '';
      this.queryParams.region = '';
    },

    getQueryregions(value) {
      this.queryRegions = this.regionslist.filter(item => parseInt(item.parentId) == parseInt(value));
      this.queryParams.region = '';
    },



    getQueryCitysAim(value) {
      this.queryCitysAim = this.cityslist.filter(item => parseInt(item.parentId) == parseInt(value));
      this.queryParams.aimCity = '';
      this.queryParams.aimRegion = '';
    },

    getQueryregionsAim(value) {
      this.queryRegionsAim = this.regionslist.filter(item => parseInt(item.parentId) == parseInt(value));
      this.queryParams.aimRegion = '';
    },





    getCitys(value) {
      this.citys = this.cityslist.filter(item => parseInt(item.parentId) == parseInt(value));
      this.form.city = '';
      this.form.region = '';
    },

    getregions(value) {
      this.regions = this.regionslist.filter(item => parseInt(item.parentId) == parseInt(value));
      this.form.region = '';
    },


    getCitysAim(value) {
      this.citysAim = this.cityslist.filter(item => parseInt(item.parentId) == parseInt(value));
      this.form.aimCity = '';
      this.form.aimRegion = '';
    },

    getregionsAim(value) {
      this.regionsAim = this.regionslist.filter(item => parseInt(item.parentId) == parseInt(value));
      this.form.aimRegion = '';
    },


    /** 查询【请填写功能名称】列表 */
    getList() {
      this.loading = true;
      listClue(this.queryParams).then(response => {
        this.clueList = response.rows;
        this.total = response.total;
        this.loading = false;
        this.togetclueStatistState();
      });
    },

    getlistAllTypes() {
      var param1 = {};
      getlistAllTypes(param1).then(response => {
        this.taglistOptions = response.data;
      });
    },


    listChina() {
      var param2 = {
        pageNum: 1,
        pageSize: 1000
      };
      listChina(this.param2).then(response => {
        this.chinaList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },

    // 取消按钮
    cancel() {
      this.open = false;
      this.openStep = false;
      this.addOpen = false;
      this.reset();
    },

    resetQueryForm() {
      this.queryParams = {
        pageNum: 1,
        pageSize: 10,
        kznum: null,
        kzplatform: null,
        kzaccount: null,
        sourceWeb: null,
        kzNickname: null,
        vehicleEstimationValue: null,
        kzphoneNumber: null,
        vehicleTypeOne: null,
        vehicleTypeTwo: null,
        followupTime: null,
        currentFollowupMan: null,
        status: null,
        acceptCompany: null,
        originPlace: null,
        aimPlace: null,
        transFee: null,
        priceNum: null,
        priceTime: null,
        price: null,
        tags: null,
        remarks: null,
        startfollowupTime: null,
        endfollowupTime: null,
        startKzTime: null,
        endKzTime: null,
        province: null,
        city: null,
        region: null,
        aimProvince: null,
        aimCity: null,
        aimRegion: null,
      }
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        kznum: null,
        kzplatform: null,
        kzaccount: null,
        sourceWeb: null,
        kzNickname: null,
        vehicleEstimationValue: null,
        kzphoneNumber: null,
        vehicleTypeOne: null,
        vehicleTypeTwo: null,
        followupTime: null,
        currentFollowupMan: null,
        status: null,
        acceptCompany: null,
        originPlace: null,
        aimPlace: null,
        transFee: null,
        priceNum: null,
        priceTime: null,
        price: null,
        tags: null,
        createTime: null,
        remarks: null,
        province: null,
        city: null,
        region: null,
        aimProvince: null,
        aimCity: null,
        aimRegion: null,
      };
      this.resetForm("form");
    },

    ///跟进form
    stepFormReset() {
      this.stepForm = {
        clueId: null,
        content: null,
        stepUserName: null,
        stepName: null,
        createTime: null,
        remarks: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      if (this.queryParams.startfollowupTime != undefined) {
        this.queryParams.startfollowupTime = this.queryParams.startfollowupTime.substring(0, 10) + " 00:00:00";
      }
      if (this.queryParams.endfollowupTime != undefined) {
        this.queryParams.endfollowupTime = this.queryParams.endfollowupTime.substring(0, 10) + " 23:59:59";
      }

      if (this.queryParams.startKzTime != undefined) {
        this.queryParams.startKzTime = this.queryParams.startKzTime.substring(0, 10) + " 00:00:00";
      }

      if (this.queryParams.endKzTime != undefined) {
        this.queryParams.endKzTime = this.queryParams.endKzTime.substring(0, 10) + " 23:59:59";
      }

      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.queryParams = {};
      //  this.resetQueryForm();
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length !== 1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.addOpen = true;
      this.title = "修改";
    },

    handleStep(row) {
      this.stepFormReset();
      this.currentPhone = row.kzphoneNumber;
      const id = row.id || this.ids;
      this.currentStatus = row.status;
      this.openStep = true;
      this.stepForm.clueId = id;
    },


    /** 提交按钮 */
    submitStepForm() {
      this.$refs["stepForm"].validate(valid => {
        if (valid) {
          if (this.currentStatus < 2) {
            this.stepForm.status = 1;
          } else {
            this.stepForm.status = currentStatus;
          }

          this.stepForm.clueId = this.currentClueId;
          addStep(this.stepForm).then(response => {
            this.$modal.msgSuccess("跟进成功");
            this.stepFormReset();
            this.open = false;
            this.openStep = false;
            this.addOpen = false;
            // this.getList();
          });
          //同时修改
          this.submitForm();
        }
      });
    },

    //查看主播详情；
    checkAnchor(row) {
      const userId = row.anchorId;
      getUser(userId).then(response => {
        this.anchorInfo = response.data;
        this.anchorOpen = true;
      });
    },

    checkInfo(row, typeParam) {
      this.checkOpen = true;
      this.handleUpdate(row, typeParam);
    },
    /** 修改按钮操作 */
    handleUpdate(row, typeParam) {
      this.reset();
      this.operateType = typeParam;
      const id = row.id || this.ids;
      this.currentClueId = id;
      this.citys = this.cityslist.filter(item => parseInt(item.parentId) == parseInt(row.province));
      this.regions = this.regionslist.filter(item => parseInt(item.parentId) == parseInt(row.city));
      this.citysAim = this.cityslist.filter(item => parseInt(item.parentId) == parseInt(row.aimProvince));
      this.regionsAim = this.regionslist.filter(item => parseInt(item.parentId) == parseInt(row.aimCity));
      getClue(id).then(response => {
        this.form = response.data;
        if (typeParam == 2) {
          this.open = true;
          this.title = "修改";
        }

      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        ///////////////////////
        this.form.aimProvinceStrings = (this.provinces.filter(item => parseInt(item.id) == parseInt(this.form.aimProvince)));
        if (this.form.aimProvinceStrings.length > 0) {
          this.form.aimProvinceString = this.form.aimProvinceStrings[0].cityName;
        }
        this.form.aimCityStrings = (this.cityslist.filter(item => parseInt(item.id) == parseInt(this.form.aimCity)));
        if (this.form.aimCityStrings.length > 0) {
          this.form.aimCityString = this.form.aimCityStrings[0].cityName;
        }
        this.form.aimRegionStrings = (this.regionslist.filter(item => parseInt(item.id) == parseInt(this.form.aimRegion)));
        if (this.form.aimRegionStrings.length > 0) {
          this.form.aimRegionString = this.form.aimRegionStrings[0].cityName;
        }
        this.form.provinceStrings = (this.provinces.filter(item => parseInt(item.id) == parseInt(this.form.province)));
        if (this.form.provinceStrings.length > 0) {
          this.form.provinceString = this.form.provinceStrings[0].cityName;
        }
        this.form.cityStrings = (this.cityslist.filter(item => parseInt(item.id) == parseInt(this.form.city)));
        if (this.form.cityStrings.length > 0) {
          this.form.cityString = this.form.cityStrings[0].cityName;
        }
        this.form.regionStrings = (this.regionslist.filter(item => parseInt(item.id) == parseInt(this.form.region)));
        if (this.form.regionStrings.length > 0) {
          this.form.regionString = this.form.regionStrings[0].cityName;
        }
        //////////////////////////////////
        if (valid) {
          if (this.form.id != null) {
            updateClue(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.addOpen = false;
              this.getList();
            });
          } else {
            addClue(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.addOpen = false;
              this.getList();
            });
          }
        }
      });
    },

    submitPriceForm() {
      this.form.status = 2;
      this.submitForm();
    },

    /** 移交报价 */

    toPrice(row) {
      const id = row.id || this.ids
      this.reset();
      this.form.id = id;
      this.form.status = 2;
      updateClue(this.form).then(response => {
        this.$modal.msgSuccess("移交成功");
        this.open = false;
        this.getList();
      });
    },

    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$modal.confirm('是否确认删除【请填写功能名称】编号为"' + ids + '"的数据项？').then(function () {
        return delClue(ids);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => { });
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('crm/clue/export', {
        ...this.queryParams
      }, `clue_${new Date().getTime()}.xlsx`)
    }
  }
};
</script>
<style lang="scss" scoped>
.row-between {
  display: flex;
  flex-flow: row nowrap;
  justify-content: space-between;
}

::v-deep .el-timeline-item__node {
  background-color: #02A7F0 !important;
}

::v-deep .el-timeline-item__tail {
  position: absolute;
  left: 4px;
  height: 100%;
  border-left: 2px solid #02A7F0;
}
</style>
